package com.hqj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hqj.controller.vo.HomeAllVo;
import com.hqj.dao.FileListMapper;
import com.hqj.entity.FileList;
import com.hqj.service.FileListService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.awt.geom.QuadCurve2D;
import java.util.HashSet;
import java.util.List;

/**
 * @author 黄啟军
 * @version 1.0
 * @date 2020/5/16/016
 */
@Service
public class FileListServiceImpl implements FileListService {
    @Resource
    private FileListMapper fileListMapper;
    @Override
    public List<FileList> findAll() {
        QueryWrapper<FileList> wrapper = new QueryWrapper<>();
        wrapper.eq("parent_id",0);
        List<FileList> fileLists = fileListMapper.selectList(wrapper);
        for (FileList fileList : fileLists){
            QueryWrapper<FileList> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("parent_id",fileList.getId());
           fileList.setListList(fileListMapper.selectList(queryWrapper));
            queryWrapper = null;
        }
        return fileLists;
    }
    @Override
    public HashSet<HomeAllVo> fileAll() {
        QueryWrapper<FileList> wrapper = new QueryWrapper<>();
        wrapper.eq("parent_id",0);
        List<FileList> lists = fileListMapper.selectList(wrapper);
        HashSet<HomeAllVo> fileLists = new HashSet<>();
        for(FileList fileList:lists){
            HomeAllVo allVo = new HomeAllVo();
            allVo.setClassifyCode(fileList.getId());
            allVo.setClassifyName(fileList.getName());
            fileLists.add(allVo);
        }
        return fileLists;
    }
}
